www.gusucode.com > 6KBBS ASP版 V7.1 > 6KBBS ASP版 V7.1\code\bbs\Addtopic.asp

    <!--#include file="up.asp"-->
<%if isnull(lguserid) or lguserid="" then:Response.Redirect"login.asp"
if checknum(session(prefix&"usertype2"))=1 or checknum(session(prefix&"usertype2"))=3 then
tl=" 操 作 失 败"
mes="<b>对不起,你不能发帖。</b><br>·你被管理员禁止发言。"
call sendinfo(tl,mes)
call down
response.end
end if
dim quoteid,topictype,postto,topic,sets,bid
session(prefix&"uploadingnum")=0
function ubbs(str)
dim re,restr
Set re=new RegExp
re.IgnoreCase=true
re.Global=True
restr="[color=808080]…… 加密内容不能引用 ……[/color]"
re.Pattern="(\[showdate=(.[^\[]*)\])((.|\n)+?)(\[\/s\])"
str=re.Replace(str,restr)

re.Pattern="(\[showtoname=(.[^\[]*)\])((.|\n)+?)(\[\/s\])"
str=re.Replace(str,restr)	

re.Pattern="(\[showtoreply\])((.|\n)+?)(\[\/s\])"
str=re.Replace(str,restr)	

re.Pattern="(\[slogin\])((.|\n)+?)(\[\/s\])"
str=re.Replace(str,restr)	


re.Pattern="(\[showtograde=*([0-9]*)\])((.|\n)+?)(\[\/s\])"
str=re.Replace(str,restr)


re.Pattern="(\[smark=*([0-9]*)\])((.|\n)+?)(\[\/s\])"
str=re.Replace(str,restr)

re.Pattern="(\[quote\])((.|\n)+?)(\[\/quote\])"
str=re.Replace(str,"")

str = replace(str, ">", "&gt;")
str = replace(str, "<", "&lt;")
set re=Nothing
ubbs=str
end function
checklg()
%>

<SCRIPT>
function set_cookie (name, value) {
        var argv = set_cookie.arguments;
        var argc = set_cookie.arguments.length;
        var expires = new Date();
        var path = (argc > 3) ? argv[3] : null;
        var domain = (argc > 4) ? argv[4] : null;

        expires.setYear(4002);
        expires.setMonth(10);
        expires.setDate(1);
        expires.setHours(2);
        expires.setMinutes(3);

        st = name+"="+escape (value)+"; expires=" + expires.toGMTString()+ ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) ;
         document.cookie =st;
}

function get_cookie(name) {
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        while (i < clen) {
                var j = i + alen;
                if (document.cookie.substring(i, j) == arg) {
                        offset=j;
                        var endstr = document.cookie.indexOf (";", offset);
                        if (endstr == -1)
                                endstr = document.cookie.length;
                        return unescape (document.cookie.substring(offset, endstr));
                }
                i = document.cookie.indexOf(" ", i) + 1;
                if (i == 0)
                        break;
        }
        return null;
}


function showvote(){
if (document.getElementById("voteyn").checked == true) {
document.getElementById("vote").style.display = "";
}else{
document.getElementById("vote").style.display = "none";
}
}
function preview()
{
if(htmlsubmit()){
document.form1.topic.value=document.topicform.topic.value;
document.form1.content.value=document.topicform.content.value;
var popupWin = window.open('paper.asp?action=preview', 'showgg', 'width=500,height=400,resizable=1,scrollbars=yes,menubar=no,status=yes');
document.form1.submit()
}
}

function checkeditor(editor)
{
if(editor=="html")
	{
				document.getElementById("ubbeditordiv").style.display = 'none';
				document.getElementById("htmltoolbar").style.display = 'block';
				EDITFORM_DOCUMENT.body.innerHTML = document.getElementById("CodeForm").value;
				document.getElementById("editTextarea").style.display = 'none';
				document.getElementById("editIframe").style.display = 'block';
				HtmlDisableToolbar(false);
	}
else if(editor=="ubb")
	{
				document.getElementById("ubbeditordiv").style.display = 'block';
				document.getElementById("htmltoolbar").style.display = 'none';
				document.getElementById("CodeForm").value = HtmlHtmlToXhtml(EDITFORM_DOCUMENT.body.innerHTML);
				document.getElementById("editIframe").style.display = 'none';
				document.getElementById("editTextarea").style.display = 'block';
				HtmlDisableToolbar(true);
	}
}


</SCRIPT>

<%
quoteid=checknum(request.querystring("quoteid"))
topictype=checknum(request.querystring("topictype"))
bid=checknum(request.querystring("bid"))
if topictype=1 then
postto="savetopic.asp?bd="&bd&"&topictype=1"
topic=""
%>

<%elseif topictype=2 then
postto="savetopic.asp?bd="&bd&"&bid="&bid&"&topictype=2&totable="&totable&""
topic="回复ID:"&bid&""
end if%>


<div class=addtopictitle>发表帖子</div>

<div class=addtopicbody>
	<form name="topicform" method="POST" action="<%=postto%>">

    <table class=addtopictable cellpadding="0" style="border-collapse: collapse" width="100%">
      <tr>
        <td width="200" ><p style="line-height: 150%; margin: 5">
       <b>帖子主题:</b></td>
        <td>&nbsp;<input type=text name=topic id="topic" size=80 maxlength=50 value="<%=topic%>" onkeydown="if(event.keyCode==13)return false;"> <SELECT name=font onchange=DoTitle(this.options[this.selectedIndex].value) style="font-size: 9pt">
<OPTION selected value="">话题</OPTION> <OPTION value=[原创]>[原创]</OPTION><OPTION value=[转帖]>[转帖]</OPTION><OPTION value=[讨论]>[讨论]</OPTION><OPTION value=[求助]>[求助]</OPTION><OPTION value=[推荐]>[推荐]</OPTION><OPTION value=[公告]>[公告]</OPTION><OPTION value=[注意]>[注意]</OPTION><OPTION value=[贴图]>[贴图]</OPTION><OPTION value=[建议]>[建议]</OPTION> <OPTION value=[下载]>[下载]</OPTION></SELECT></td>
      </tr>
      <tr>
        <td width="200">
        <p style="line-height: 150%; margin: 5"><b>你的表情:</b> <br>·放在帖子前面。</td>
        <td><p style="line-height: 150%; margin: 5"><script>
for(i=1;i<=18;i=i+1) {
if (i==10){document.write("<p style='line-height: 150%; margin: 5'>")}
if (i==1){document.write("<input type=radio value=face"+i+" name=face checked><img border=0 src=images/face/face"+i+".gif>")}
else {document.write("<input type=radio value=face"+i+" name=face><img border=0 src=images/face/face"+i+".gif>")}
}
        </script> </td>
      </tr>
<tr>
        <td width="200">
        <p style="margin: 5"><b>文件上传:</b><br>·上传一个文件需要10点积分。</td>
<td>
<p style="margin: 5"><%if checknum(application(prefix&"canupload"))=1 then%><IFRAME name=ad src="upload.asp" frameBorder=0 width="100%" scrolling=no height=36></IFRAME><%else%>论坛不支持上传文件。<%end if%></td>
      </tr>      
      <tr>
        <td  valign="top" width="200">
        <p style="line-height: 150%; margin: 5"><b>帖子内容:</b><br>限制25600个字符。<br>(对简单的内容自动保存)<br>
		<input type="radio" name="usereditor" value="html" onclick="checkeditor('html')" checked>使用Html编辑器<br>
		<input type="radio" name="usereditor" value="ubb" onclick="checkeditor('ubb')">使用UBB编辑器<br>
<%if topictype=1 then %><input type="checkbox" onclick=showvote() name="voteyn" id="voteyn" value="1" <%if checknum(request.querystring("vote"))=1 then%>checked<%end if%>> 显示投票选项<br><%end if%>
</td>
<td valign="top" style="padding:5px;">
<textarea name="content" cols="40" rows="2" style="display:none"></textarea>
<SCRIPT src="Editor/Ubb/UbbEditor.js"></SCRIPT>
<script type="text/javascript" src="Editor/Html/htmlEditor.js"></script>

<script type="text/javascript">
var cookiesstr=get_cookie("tempcontent");
if (cookiesstr==null)cookiesstr="";
document.getElementsByName("content").item(0).value = cookiesstr;

</script>


<script type="text/javascript">
var ubbedit=new UbbEditor("CodeForm",100,14,"default values","editor/ubb/images/");
ubbedit.showeditor();
var editor = new htmlEditor("editor");
editor.hiddenName = "content";
editor.width = "100%";
editor.height = "300px";
editor.imagePath="editor/html/images/";
editor.iconPath = 'editor/html/images/face/';
editor.show();

var strlength;

//提交表单
function submitform(){
   	if(htmlsubmit()==true)document.topicform.submit();
}

//检测表单
function htmlsubmit() {
	if(document.getElementsByName("usereditor").item(0).checked==true){
		var content = editor.data();
	}
	else if(document.getElementsByName("usereditor").item(1).checked==true){
		checkeditor("html");
		var content = editor.data();
		checkeditor("ubb");
	}
	
		strlength=document.getElementsByName("content").item(0).value.length;
		if (strlength>25600||strlength<5){
			alert("您输入的文章长度为"+strlength+",长度必须大于5且小于25600,请修正之后再继续。");
			return false;
		}
		else if(document.getElementsByName("topic").item(0).value==""){
			alert("标题不能为空。");
			document.getElementById("topic").style.backgroundColor="#FFEEEE";
			return false;
		}
		else{
			return true;
		}
}

function autosave(){
	if(document.getElementsByName("usereditor").item(0).checked==true){
		var content = editor.data();
	}
	else if(document.getElementsByName("usereditor").item(1).checked==true){
		document.getElementsByName("content").item(0).value = document.getElementById("CodeForm").value;
	}
	set_cookie("tempcontent",document.getElementsByName("content").item(0).value);
}


setInterval("autosave()",5000);

function presskey(eventobject)
{
var eve=eventobject||window.event;
   if(eve.ctrlKey && eve.keyCode==13){submitform();}else{return false}
}

</script>

</td>
      </tr>
      <tr id=vote style="DISPLAY: <%if checknum(request.querystring("vote"))<>1 then%>none<%end if%>">
        <td  valign="top" width="200">
        <p style="line-height: 150%; margin: 5"><b>投票项目:</b>最多<%=application(prefix&"voten")%>个选项。<br>·各个项目用回车隔开<br>
<input type="radio" name="votetype" value="1" checked>单选&nbsp;
<input type="radio" name="votetype" value="2">多选</p>
<p style="margin: 5; ; line-height:150%"><b>过期时间:</b><select size="1" name="outtime" style="font-size: 9pt">
<option value="1">一天</option>
<option value="3">三天</option>
<option value="7">一周</option>
<option value="15">半个月</option>
<option value="31">一个月</option>
<option value="93">三个月</option>
<option value="365">一年</option>
<option value="10000" selected>不过期</option>
</select></p></td>
        <td valign="top">
        <p style="margin: 5">
        <textarea rows=7 onkeydown="presskey(event)" name=vote cols=82 Title='按 Ctrl+Enter 直接发送'></textarea></p></td>
      </tr>
      <tr>
        <td width="200">
         </td>
        <td height="30">
&nbsp;<input class=submit type=button value=OK_!发表 name="B1" onclick="submitform()">&nbsp;&nbsp;&nbsp; 
    <input class=submit type=button value="预  览!" onclick="preview()" name="B3">&nbsp;&nbsp;&nbsp; <input class=submit type=reset value=NO_!重写 name=B2>&nbsp; [ 按 Ctrl+Enter 直接发送 ]</td>
      </tr>
      </table>
    </form></div>

<form name=form1 action=paper.asp?action=preview method=post target=showgg>
<input type=hidden name=topic value=><input type=hidden name=content value=>
</form>
<script>function putinstrHTML(str){
var documentedit;
var browserthis=HtmlGetBrowser();
		if (browserthis== 'IE') {
			documentedit = document.frames("EditForm").document;
		} else {
			documentedit = document.getElementById('EditForm').contentDocument;
		}

documentedit.body.innerHTML+=str;
}
function putinstrUBB(str){
	var documentedit=document.getElementById('CodeForm');
	documentedit.value+=str;
}
</script>

<%
if quoteid<>"" then
	dim quote,qcontent,qcontentok
	set quote=conn.execute("select top 1 content from bbs"&totable&" where bbsid="&quoteid&"")
		qcontent=quote("content")
		qcontent=split(qcontent,"|")
	set quote=nothing
	qcontentok="[quote]<br />[B]以下是引用[i]"&qcontent(2)&"在"&qcontent(5)&"[/i]的发言:[/B]<br />"&ubbs(qcontent(4))&"<br />[/quote]"
	response.write "<textarea id=qtextarea style='display:none;'>"&qcontentok&"</textarea>"
%>

<script>
var text=document.getElementById("qtextarea").value;

putinstrHTML(text);
</script>

<%	
end if
%>

<%call down%>